﻿using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 基于WPF的电缆采样数据分析系统.Models.Enums;
using 基于WPF的电缆采样数据分析系统.Tools.LangugeTool;

namespace 基于WPF的电缆采样数据分析系统.ViewModels.TDRWork.OptionPage
{
    public class DefaultParameterUCViewModel : BindableBase
    {

        /// <summary>
        /// 构造器
        /// </summary>
        public DefaultParameterUCViewModel()
        {
            // 绑定通道切换命令
            ChannelChangedCmm = new DelegateCommand<int?>(ChannelChangedFun);
        }



        #region 描述信息
        /// <summary>
        /// 描述信息
        /// </summary>
        private string _TaskContent = GlobalVariableEdit.TaskContent;

        /// <summary>
        /// 描述信息
        /// </summary>
        public string TaskContent
        {
            get { return _TaskContent; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _TaskContent = value;
                GlobalVariableEdit.TaskContent = value;
                RaisePropertyChanged();
            }
        }


        #endregion

        #region 通道信息
        /// <summary>
        /// 通道信息
        /// </summary>
        private int _CurrentChannelIndex = (int)GlobalVariableEdit.CurrentChannelIndex;

        /// <summary>
        /// 通道信息
        /// </summary>
        public int CurrentChannelIndex
        {
            get { return _CurrentChannelIndex; }
            set { 
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _CurrentChannelIndex = value;
                GlobalVariableEdit.CurrentChannelIndex = (PassageType)value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 切换通道方法
        /// </summary>
        public DelegateCommand<int?> ChannelChangedCmm { get; set; }

        /// <summary>
        /// 切换通道方法
        /// </summary>
        /// <param name="selectedIndex"></param>
        private void ChannelChangedFun(int? selectedIndex)
        {
            CurrentChannelIndex = (int)selectedIndex;
        }

        #endregion

        #region 水平参数信息

        /// <summary>
        /// 任务默认X轴起点
        /// </summary>
        private float _XAxisStartPoint = GlobalVariableEdit.XAxisStartPoint;

        /// <summary>
        /// 任务默认X轴起点
        /// </summary>
        public float XAxisStartPoint
        {
            get { return _XAxisStartPoint; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _XAxisStartPoint = value;
                GlobalVariableEdit.XAxisStartPoint = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 任务默认X轴终点
        /// </summary>
        private float _XAxisEndPoint = GlobalVariableEdit.XAxisEndPoint;

        /// <summary>
        /// 任务默认X轴终点
        /// </summary>
        public float XAxisEndPoint
        {
            get { return _XAxisEndPoint; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _XAxisEndPoint = value;
                GlobalVariableEdit.XAxisEndPoint = value;
                RaisePropertyChanged();
            }
        }

        /// <summary>
        /// 任务默认X轴刻度
        /// </summary>
        private float _XAxisScale = GlobalVariableEdit.XAxisScale;


        /// <summary>
        /// 任务默认X轴刻度
        /// </summary>
        public float XAxisScale
        {
            get { return _XAxisScale; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _XAxisScale = value;
                GlobalVariableEdit.XAxisScale = value;
                RaisePropertyChanged();
            }
        }


        #endregion

        #region 垂直参数信息

        /// <summary>
        /// 任务默认Y轴起点
        /// </summary>
        private float _YAxisStartPoint = GlobalVariableEdit.YAxisStartPoint;

        /// <summary>
        /// 任务默认Y轴起点
        /// </summary>
        public float YAxisStartPoint
        {
            get { return _YAxisStartPoint; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _YAxisStartPoint = value;
                GlobalVariableEdit.YAxisStartPoint = value;
                RaisePropertyChanged();
            }
        }


        /// <summary>
        /// 任务默认Y轴终点
        /// </summary>
        private float _YAxisEndPoint = GlobalVariableEdit.YAxisEndPoint;

        /// <summary>
        /// 任务默认Y轴终点
        /// </summary>
        public float YAxisEndPoint
        {
            get { return _YAxisEndPoint; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _YAxisEndPoint = value;
                GlobalVariableEdit.YAxisEndPoint = value;
                RaisePropertyChanged();
            }
        }


        /// <summary>
        /// 任务默认Y轴刻度
        /// </summary>
        private float _YAxisScale = GlobalVariableEdit.YAxisScale;

        /// <summary>
        /// 任务默认Y轴刻度
        /// </summary>
        public float YAxisScale
        {
            get { return _YAxisScale; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _YAxisScale = value;
                GlobalVariableEdit.YAxisScale = value;
                RaisePropertyChanged();
            }
        }

        #endregion


        #region 波形平移
        /// <summary>
        /// X轴平移
        /// </summary>
        private float _XAxisTranslation = GlobalVariableEdit.XAxisTranslation;
        /// <summary>
        /// X轴平移
        /// </summary>
        public float XAxisTranslation
        {
            get { return _XAxisTranslation; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _XAxisTranslation = value;
                GlobalVariableEdit.XAxisTranslation = value;
                RaisePropertyChanged();
            }
        }


        /// <summary>
        /// Y轴平移
        /// </summary>
        private float _YAxisTranslation = GlobalVariableEdit.YAxisTranslation;
        /// <summary>
        /// Y轴平移
        /// </summary>
        public float YAxisTranslation
        {
            get { return _YAxisTranslation; }
            set {
                if (OptionUCViewModel.Instance.DefaultParamUpdate == 0)
                {
                    OptionUCViewModel.Instance.DefaultParamUpdate = 1;
                }
                _YAxisTranslation = value;
                GlobalVariableEdit.YAxisTranslation = value;
                RaisePropertyChanged();
            }
        }

        #endregion
    }
}
